package cn.dtsmusic.model.domain;

import java.io.Serializable;
import java.util.Map;

public class ResponseResult implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6384448255894279399L;

	/** 
     * 是否成功，成功找data、失败找msg 
     */  
	public final boolean success;  
  
    /** 
     * 返回结果编码，成功的话我喜欢设为0 
     */  
    public final int code;  
  
    /** 
     * 返回消息，一般放置可追溯的错误消息 
     */  
    public final String msg;  
  
    /** 
     * 返回数据 
     */  
    public final Object data;  
    
    /** 
     * 额外参数,不使用Map<String, Object>防止JSON解析时过于复杂 
     */  
    public final Map<String, String> extraInfo;  
  
    public ResponseResult(boolean success , int code ,String msg) {  
    	this(success,code ,msg,null);
    }  
    
    public ResponseResult(boolean success,int code,String msg, Object data) {  
        this(success,code ,msg,data,null);
    }  

  
    public ResponseResult(boolean success, int code, String msg, Object data,Map<String, String> extraInfo) {  
        this.success = success;  
        this.code = code;  
        this.msg = msg;  
        this.data = data;  
        this.extraInfo = extraInfo ;
    }  
      
    public static ResponseResult fail(int code, String msg,Map<String, String> extraInfo){  
        return new ResponseResult(false,code,msg,null,extraInfo);  
    }  
  
    public static ResponseResult success(Object data, Map<String, String> extraInfo){  
        return new ResponseResult(true,0,"",data,extraInfo);  
    }  
}
